package br.com.sipsoft.svola.splash;

import java.io.FileInputStream;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.JWindow;

public class SplashScreen extends JWindow {
	private static final long serialVersionUID = 1L;
	private JProgressBar progressBar;

	public SplashScreen() {
		getContentPane().setLayout(null);
		
		JLabel lblImagem = new JLabel("");
		try {
	//		ImageIcon icon = new ImageIcon(ImageIO.read(new FileInputStream("imagens/img_splash.jpg")));
	//		lblImagem.setIcon(icon);
		} catch (Exception e) {
			e.printStackTrace();
		}
		lblImagem.setBounds(0, 0, 432, 330);
		getContentPane().add(lblImagem);
		
		progressBar = new JProgressBar();
		progressBar.setStringPainted(true);
		progressBar.setBounds(0, 331, 432, 27);
		getContentPane().add(progressBar);
		setSize(432, 361);
		setLocationRelativeTo(null);
		update();
	}

	public void setMessage(String mensagem){
		progressBar.setString(mensagem);
		update();
	}

	public void setProgress(int prog) {
		progressBar.setValue(prog);
		update();
	}

	private void update(){
		update(getGraphics());
	}
}
